package com.lx.oms.controller.manager.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.utils.Utils;
import com.lx.oms.controller.dao.UserEnterpriseMapper;
import com.lx.oms.controller.entity.UserEnterpriseEntity;
import com.lx.oms.controller.manager.UserEnterpriseManager;

/**
 * 企业
 *
 * @author houzhong
 * @date 2018年7月10日 下午3:11:42
 */
@Component("userEnterpriseManager")
public class UserEnterpriseManagerImpl implements UserEnterpriseManager {

	@Autowired
	private UserEnterpriseMapper userEnterpriseMapper;
	

	@Override
	public List<UserEnterpriseEntity> listUserEnterprise(Page<UserEnterpriseEntity> page, Query search) {
		return userEnterpriseMapper.listForPage(page, search);
	}

	@Override
	public int saveUserEnterprise(UserEnterpriseEntity userEnterprise) {
		if (userEnterprise.getId() == null) {
			userEnterprise.setId(Utils.id().toString());
		}
		return userEnterpriseMapper.save(userEnterprise);
	}

	@Override
	public UserEnterpriseEntity getUserEnterpriseById(BigInteger id) {
		UserEnterpriseEntity tUserEnterprise = userEnterpriseMapper.getObjectById(id);
		return tUserEnterprise;
	}

	@Override
	public int updateUserEnterprise(UserEnterpriseEntity userEnterprise) {
		return userEnterpriseMapper.update(userEnterprise);
	}

	@Override
	public int batchRemove(String[] id) {
		int count = userEnterpriseMapper.batchRemove(id);
		return count;
	}
	
}
